include $(TOPDIR)/rules.mk

PKG_NAME:=pcs_upper
PKG_RELEASE:=1

PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/pcs_upper
	SECTION:=pcs_upper
	CATEGORY:=pcs_upper
	DEPENDS:= +libsqlite3 +libmodbus +libuci +libjson-c +libc +librt
	TITLE:=pcs_upper Gather Ingredients
endef

define Build/Configure
endef

define Package/pcs_upper/description
	pcs_upper Gather Ingredients.
endef

define Build/Prepare
	$(CP) $(TOPDIR)/package/pcs_upper/src/*  $(PKG_BUILD_DIR)
endef

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) \
	CC="$(TARGET_CC)" \
	CFLAGS="$(TARGET_CFLAGS) -Wall -ggdb3" \
	LDFLAGS="$(TARGET_LDFLAGS) -lsqlite3 -lmodbus -luci -ljson-c -lc -lrt"
endef

define Package/pcs_upper/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/pcs_upper $(1)/usr/sbin/
	$(INSTALL_DIR) $(1)/etc/config
	$(CP) $(TOPDIR)/package/pcs_upper/files/modbus $(1)/etc/config/modbus
	$(CP) $(TOPDIR)/package/pcs_upper/files/upgrade.sh $(1)/etc/config/upgrade.sh
	$(CP) $(TOPDIR)/package/pcs_upper/files/reboot.sh $(1)/etc/config/reboot.sh
	$(INSTALL_DIR) $(1)/root/debug
	$(CP) $(TOPDIR)/package/pcs_upper/files/tt.sh $(1)/root/debug/tt.sh
endef

$(eval $(call BuildPackage,pcs_upper))


